package com.example.neteaseplay;

public class PlayMode {
    public final static int MODE_PAUSE = 0;
    public final static int MODE_PLAYING = 1;
    public final static int MODE_INIT = 2;
    private int mode;

    public interface PlayModeChange {
        public void modeChange(int mode);
    }

    public PlayModeChange mPlayModeChange;

    public void init() {
        mode = MODE_INIT;
        setModeChange(mode);
    }

    public void setPlayModeChange(PlayModeChange playModeChange) {
        this.mPlayModeChange = playModeChange;
    }

    public void toggleMode() {
        if (mode == MODE_INIT || mode == MODE_PAUSE) {
            mode = MODE_PLAYING;
        } else if (mode == MODE_PLAYING) {
            mode = MODE_PAUSE;
        }
        setModeChange(mode);
    }

    public void setModeChange(int mode) {
        if (mPlayModeChange != null) {
            mPlayModeChange.modeChange(mode);
        }
    }

    public boolean isMode(int mode) {
        return this.mode == mode;
    }
    
    public void setMode(int mode) {
        this.mode = mode;
        setModeChange(mode);
    }
}
